package com.elves.auth.api;

import java.security.Principal;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ui.Model;
import org.springframework.web.servlet.ModelAndView;

// @Controller 可以到达template下面的页面
@Controller
@Slf4j
public class WebAction {

    @GetMapping("/user")
    public ModelAndView user(Principal principal, Model model) throws InterruptedException {
        log.info("home principal:{} ", principal);
        log.info("home  model:{}", model);
        ModelAndView mav = new ModelAndView();
        mav.addObject("msg", "user");
        mav.setViewName("user");
        return mav;
    }
    @GetMapping("/role")
    public ModelAndView role(Principal principal, Model model) throws InterruptedException {
        log.info("home principal:{} ", principal);
        log.info("home  model:{}", model);
        ModelAndView mav = new ModelAndView();
        mav.addObject("msg", "role");
        mav.setViewName("role");
        return mav;
    }
    @GetMapping("/app")
    public ModelAndView app(Principal principal, Model model) throws InterruptedException {
        log.info("home principal:{} ", principal);
        log.info("home  model:{}", model);
        ModelAndView mav = new ModelAndView();
        mav.addObject("msg", "app");
        mav.setViewName("app");
        return mav;
    }
    @GetMapping("/about")
    public ModelAndView about(Principal principal, Model model) throws InterruptedException {
        log.info("home principal:{} ", principal);
        log.info("home  model:{}", model);
        ModelAndView mav = new ModelAndView();
        mav.addObject("msg", "about");
        mav.setViewName("about");
        return mav;
    }

    @GetMapping("/mock")
    public ModelAndView go(Principal principal, Model model) throws InterruptedException {
        log.info("home principal:{} ", principal);
        log.info("home  model:{}", model);
        ModelAndView mav = new ModelAndView();
        mav.addObject("msg", "about");
        mav.setViewName("mock");
        return mav;
    }


    @GetMapping("/material")
    public ModelAndView materia(Principal principal, Model model) throws InterruptedException {
        log.info("home principal:{} ", principal);
        log.info("home  model:{}", model);
        ModelAndView mav = new ModelAndView();
        mav.addObject("msg", "material");
        mav.setViewName("material");
        return mav;
    }

}